
$(function(){
	if(+id)infoPatrol();

});
var dataHand = new AjaxHandler();
var id = param.id;

function infoPatrol(){
	$.proAjax({
		url: "/mobile/findpatrol",
		data: {"id":id},
		success: function (data) {
			for(var key in data){
				if($("form").find("#"+key).is("input")){
					if(key=="stime" || key=="etime"){
						$("form").find("#"+key).val(data[key]==null?"":new Date(data[key]).format("yyyy-MM-dd hh:mm"));
					}else{
						$("form").find("#"+key).val(data[key]);
					}
				}else if($("form").find("#"+key).is("textarea")){
					$("form").find("#"+key).text(data[key]);
				}
			}
			$("#tourstate > span").removeClass("on-active");
			$("#tourstate > span:eq("+data.tourstate+")").addClass("on-active");
			
			}
			
		})
	};
	/**保存*/
	function savepatrol(){
		var tourstate = $("#tourstate .on-active").attr("data-value");
		var pm={id:id,
				tourstate:tourstate
			};
		var params = $param(pm); 
		//巡视地点设置为必填项
		var place = $("#place").val();
		if(place == ""){
			mui.alert("请填写巡视地点", "提示", "确定", function(){
				$("#place").focus();
			});
			return;
		}
		$.proAjax({
			url: "/mobile/savepatrol",
			data: params,
			success: function (data) {
				//history.go(-1);
				//router.href("patrolDJ.html",{id:""});
				/*param.id="";*/
				
				mui.back();
				
			}
		});
	}


